<template>
  <div class="home">
    图片路径：<input type="text" :value="path" @change="valueChange">
    <button @click="notify">通知</button>
    <button @click="updateWinSize">修改窗口大小</button>
    <button @click="enableTray">启用托盘</button>
    <button @click="addFlashingPath">添加闪烁图片</button>
    <button @click="startFlashing">闪烁</button>
    <button @click="endFlashing">停止闪烁</button>
    <button @click="closeWindow">关闭该窗口</button>
    <button @click="minWindow">最小化该窗口</button>
    <button @click="maxWindow">最大化该窗口</button>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import HelloWorld from "@/components/HelloWorld.vue"; // @ is an alias to /src

@Component({
  components: {
    HelloWorld,
  },
})
export default class Home extends Vue {
// 图片路径
  public path = 'images/logo2.png';

  valueChange(value:any){
    this.path = value.currentTarget.value;
  }

// 通知
  public notify() {
    (this as any)
      .$ipcCallMain("window.send", {
        title: "标题",
        body: "sdjifsdhoifhwioerew",
      })
      .then((r: any) => {
        console.log(r);
      });
  }
// 
  updateWinSize() {
    (this as any)
      .$ipcCallMain("window.updateWindowSize", {
        width: 700,
        height: 500,
        animate: true,
      })
      .then((r: any) => {
        console.log(r);
      });
  }
  async enableTray() {
    await (this as any).$ipcCallMain("tray.enableTray", {
      path: "images/logo.png",
    });
  }

  addFlashingPath(){
       (this as any).$ipcCallMain("tray.addFlashingPath", {
      path: this.path,
    });
  }
  startFlashing(){
    (this as any).$ipcCallMain("tray.startFlashing", {
      time: 500,
    })
  }
  endFlashing(){
    (this as any).$ipcCallMain("tray.endFlashing", {
    })
  }

  closeWindow(){
    window.close();
  }

  minWindow(){
    (this as any).$ipcCallMain("window.minWindow", {
    })    
  }

  maxWindow(){
    (this as any).$ipcCallMain("window.maxWindow", {
    })    
  }

}
</script>
